import { PermissionParams, PermissionResponseData } from './types';

// 统一接口管理
enum API {
  GET_PERMISSION_URL = '/admin/acl/permission',
  ADD_PERMISSION_URL = '/admin/acl/permission/save',
  UPDATE_PERMISSION_URL = '/admin/acl/permission/update',
  DELETE_PERMISSION_URL = '/admin/acl/permission/remove',
}

//获取权限菜单列表
export const reqGetPermissions = () => {
  return request.get<any, PermissionResponseData>(API.GET_PERMISSION_URL);
};
//添加或者更新权限菜单
export const reqAddOrUpdatePermission = (data: PermissionParams) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATE_PERMISSION_URL, data);
  } else {
    return request.post<any, any>(API.ADD_PERMISSION_URL, data);
  }
};
//删除权限菜单
export const reqDeletePermission = (id: number) => {
  return request.delete<any, any>(API.DELETE_PERMISSION_URL + `/${id}`);
};
